/*************************************************************************
	> File Name: Builder.h
	> Author: Joker
	> Mail: mahongtao@foxmail.com 
	> Created Time: 2020-09-21 20:04:35
 ************************************************************************/

#ifndef __BUILDER_H__
#define __BUILDER_H__

//抽象基类,提供不同部分的构建接口函数
class Builder
{
public:
    Builder(){}
    virtual ~Builder(){}

    virtual void BuilderPartA() = 0;
    virtual void BuilderPartB() = 0;
};

//使用Builder构建产品，构建产品的过程都是一致的，但是不同的Builder有不同的实现
//多态实现
class Director
{
public:
    Director(Builder * pBuilder);
    ~Director();

    void Construct();

private:
    Builder * _pBuilder;
};

//Builder的派生类,实现BuilderPartA和BuilderPartB的接口函数
class ConcreateBuilder1
:public Builder
{
public:
    ConcreateBuilder1(){}
    virtual ~ConcreateBuilder1(){}

    virtual void BuilderPartA();
    virtual void BuilderPartB();
};

//Builder的派生类,实现BuilderPartA和BuilderPartB的接口函数
class ConcreateBuilder2
:public Builder
{
public:
    ConcreateBuilder2(){}
    virtual ~ConcreateBuilder2(){}

    virtual void BuilderPartA();
    virtual void BuilderPartB();
};


#endif
